namespace Repositories.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class init : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.Attachment",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        Name = c.String(nullable: false, maxLength: 50),
                        Type = c.Int(nullable: false),
                        Address = c.String(nullable: false, maxLength: 500),
                        Suffix = c.String(nullable: false, maxLength: 8),
                        CreateTime = c.DateTime(nullable: false),
                        RowVersion = c.Binary(nullable: false, fixedLength: true, timestamp: true, storeType: "rowversion"),
                        PaymentEntrust_ID = c.Int(),
                        Contract_ID = c.Int(),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.PaymentEntrust", t => t.PaymentEntrust_ID)
                .ForeignKey("dbo.Contract", t => t.Contract_ID)
                .Index(t => t.PaymentEntrust_ID)
                .Index(t => t.Contract_ID);
            
            CreateTable(
                "dbo.Branch",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        Name = c.String(nullable: false, maxLength: 50),
                        Type = c.Int(nullable: false),
                        Status = c.Boolean(nullable: false),
                        GrossMargin = c.Decimal(nullable: false, precision: 18, scale: 4),
                        CounterFeeRate = c.Decimal(nullable: false, precision: 18, scale: 4),
                        ArrearsTotal = c.Decimal(nullable: false, precision: 18, scale: 2),
                        OweTicketsDay = c.Int(nullable: false),
                        CreaterId = c.Int(nullable: false),
                        CreateTime = c.DateTime(nullable: false),
                        UpdaterId = c.Int(),
                        UpdaterName = c.String(maxLength: 20),
                        UpdateTime = c.DateTime(),
                        RowVersion = c.Binary(nullable: false, fixedLength: true, timestamp: true, storeType: "rowversion"),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.User", t => t.CreaterId)
                .ForeignKey("dbo.User", t => t.UpdaterId)
                .Index(t => t.CreaterId)
                .Index(t => t.UpdaterId);
            
            CreateTable(
                "dbo.User",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        Login = c.String(nullable: false, maxLength: 20),
                        PassWord = c.String(nullable: false, maxLength: 32),
                        Name = c.String(nullable: false, maxLength: 20),
                        IsSpecialManager = c.Boolean(nullable: false),
                        Type = c.Int(nullable: false),
                        Status = c.Int(nullable: false),
                        Phone = c.String(nullable: false, maxLength: 11),
                        BranchId = c.Int(),
                        SpecialId = c.Int(),
                        CreaterId = c.Int(),
                        CreateTime = c.DateTime(),
                        UpdaterId = c.Int(),
                        UpdateTime = c.DateTime(),
                        RowVersion = c.Binary(nullable: false, fixedLength: true, timestamp: true, storeType: "rowversion"),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.Branch", t => t.BranchId)
                .ForeignKey("dbo.User", t => t.CreaterId)
                .ForeignKey("dbo.Special", t => t.SpecialId)
                .ForeignKey("dbo.User", t => t.UpdaterId)
                .Index(t => t.BranchId)
                .Index(t => t.SpecialId)
                .Index(t => t.CreaterId)
                .Index(t => t.UpdaterId);
            
            CreateTable(
                "dbo.Menu",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        Name = c.String(nullable: false, maxLength: 20),
                        Code = c.String(nullable: false, maxLength: 8),
                        Url = c.String(nullable: false, maxLength: 500),
                        Status = c.Boolean(nullable: false),
                        Sort = c.Int(nullable: false),
                        UserMenu = c.Int(nullable: false),
                        UpMenuId = c.Int(),
                        RowVersion = c.Binary(nullable: false, fixedLength: true, timestamp: true, storeType: "rowversion"),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.Menu", t => t.UpMenuId)
                .Index(t => t.UpMenuId);
            
            CreateTable(
                "dbo.Special",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        Name = c.String(nullable: false, maxLength: 50),
                        Code = c.String(nullable: false, maxLength: 21),
                        BranchId = c.Int(nullable: false),
                        Status = c.Int(nullable: false),
                        ChargeName = c.String(nullable: false, maxLength: 20),
                        ChargePhone = c.String(nullable: false, maxLength: 11),
                        ChargePaperType = c.String(nullable: false, maxLength: 20),
                        ChargePaperNumber = c.String(nullable: false, maxLength: 30),
                        ChargeBank = c.String(nullable: false, maxLength: 30),
                        ChargeBankNumber = c.String(nullable: false, maxLength: 20),
                        CompanyBank = c.String(nullable: false, maxLength: 30),
                        CompanyNumber = c.String(nullable: false, maxLength: 20),
                        EndDate = c.DateTime(nullable: false),
                        CreaterId = c.Int(nullable: false),
                        CreaterName = c.String(nullable: false, maxLength: 20),
                        CreateTime = c.DateTime(nullable: false),
                        UpdaterId = c.Int(nullable: false),
                        UpdaterName = c.String(nullable: false, maxLength: 20),
                        UpdateTime = c.DateTime(nullable: false),
                        RowVersion = c.Binary(nullable: false, fixedLength: true, timestamp: true, storeType: "rowversion"),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.Branch", t => t.BranchId)
                .ForeignKey("dbo.User", t => t.CreaterId)
                .ForeignKey("dbo.User", t => t.UpdaterId)
                .Index(t => t.BranchId)
                .Index(t => t.CreaterId)
                .Index(t => t.UpdaterId);
            
            CreateTable(
                "dbo.SpecialCapital",
                c => new
                    {
                        ID = c.Int(nullable: false),
                        Balance = c.Decimal(nullable: false, precision: 18, scale: 4),
                        Profit = c.Decimal(nullable: false, precision: 18, scale: 4),
                        Gathering = c.Decimal(nullable: false, precision: 18, scale: 4),
                        Payment = c.Decimal(nullable: false, precision: 18, scale: 4),
                        InvoiceSend = c.Decimal(nullable: false, precision: 18, scale: 4),
                        InvoiceCollect = c.Decimal(nullable: false, precision: 18, scale: 4),
                        WithHold = c.Decimal(nullable: false, precision: 18, scale: 4),
                        RowVersion = c.Binary(nullable: false, fixedLength: true, timestamp: true, storeType: "rowversion"),
                        Special_ID = c.Int(),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.Special", t => t.Special_ID)
                .ForeignKey("dbo.Special", t => t.ID)
                .Index(t => t.ID)
                .Index(t => t.Special_ID);
            
            CreateTable(
                "dbo.CollectInvoiceDetail",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        CollectInvoiceId = c.Int(nullable: false),
                        GroupId = c.Int(nullable: false),
                        Code = c.String(nullable: false, maxLength: 50),
                        Company = c.String(nullable: false, maxLength: 100),
                        Type = c.Int(nullable: false),
                        Money = c.Decimal(nullable: false, precision: 18, scale: 4),
                        Content = c.String(maxLength: 500),
                        Date = c.DateTime(nullable: false),
                        RowVersion = c.Binary(nullable: false, fixedLength: true, timestamp: true, storeType: "rowversion"),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.CollectInvoice", t => t.CollectInvoiceId)
                .ForeignKey("dbo.CollectInvoiceGroup", t => t.GroupId)
                .Index(t => t.CollectInvoiceId)
                .Index(t => t.GroupId);
            
            CreateTable(
                "dbo.CollectInvoice",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        PaymentId = c.Int(nullable: false),
                        Status = c.Int(nullable: false),
                        CreaterId = c.Int(nullable: false),
                        Remark = c.String(maxLength: 200),
                        CreateTime = c.DateTime(nullable: false),
                        RowVersion = c.Binary(nullable: false, fixedLength: true, timestamp: true, storeType: "rowversion"),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.User", t => t.CreaterId)
                .ForeignKey("dbo.Payment", t => t.PaymentId)
                .Index(t => t.PaymentId)
                .Index(t => t.CreaterId);
            
            CreateTable(
                "dbo.CollectInvoiceGroup",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        CollectInvoiceId = c.Int(nullable: false),
                        GroupCode = c.String(nullable: false, maxLength: 20),
                        Name = c.String(nullable: false, maxLength: 100),
                        RowVersion = c.Binary(nullable: false, fixedLength: true, timestamp: true, storeType: "rowversion"),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.CollectInvoice", t => t.CollectInvoiceId)
                .Index(t => t.CollectInvoiceId);
            
            CreateTable(
                "dbo.Payment",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        SpecialId = c.Int(nullable: false),
                        SpecialName = c.String(nullable: false, maxLength: 20),
                        SupplyId = c.Int(nullable: false),
                        Status = c.Int(nullable: false),
                        Payee = c.String(nullable: false, maxLength: 20),
                        CollectionBank = c.String(nullable: false, maxLength: 30),
                        BankNumber = c.String(nullable: false, maxLength: 20),
                        SerialNumber = c.String(maxLength: 100),
                        Money = c.Decimal(nullable: false, precision: 18, scale: 4),
                        CounterFee = c.Decimal(nullable: false, precision: 18, scale: 4),
                        ApplicantName = c.String(nullable: false, maxLength: 20),
                        ApplicationTime = c.DateTime(nullable: false),
                        AuditName = c.String(maxLength: 20),
                        AuditTime = c.DateTime(),
                        Remark = c.String(maxLength: 200),
                        RowVersion = c.Binary(nullable: false, fixedLength: true, timestamp: true, storeType: "rowversion"),
                        Applicant_ID = c.Int(nullable: false),
                        Audit_ID = c.Int(),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.User", t => t.Applicant_ID)
                .ForeignKey("dbo.User", t => t.Audit_ID)
                .ForeignKey("dbo.SellerSupplier", t => t.SupplyId)
                .ForeignKey("dbo.Special", t => t.SpecialId)
                .Index(t => t.SpecialId)
                .Index(t => t.SupplyId)
                .Index(t => t.Applicant_ID)
                .Index(t => t.Audit_ID);
            
            CreateTable(
                "dbo.PaymentEntrust",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        PaymentId = c.Int(nullable: false),
                        Payee = c.String(nullable: false, maxLength: 20),
                        CollectionBank = c.String(nullable: false, maxLength: 30),
                        BankNumber = c.String(nullable: false, maxLength: 20),
                        RowVersion = c.Binary(nullable: false, fixedLength: true, timestamp: true, storeType: "rowversion"),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.Payment", t => t.PaymentId)
                .Index(t => t.PaymentId);
            
            CreateTable(
                "dbo.SellerSupplier",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        Name = c.String(nullable: false, maxLength: 50),
                        Type = c.Int(nullable: false),
                        Status = c.Boolean(nullable: false),
                        Phone = c.String(nullable: false, maxLength: 11),
                        ChargeBankNumber = c.String(nullable: false, maxLength: 20),
                        Bank = c.String(nullable: false, maxLength: 30),
                        ChargeName = c.String(nullable: false, maxLength: 20),
                        CertificateNum = c.String(nullable: false, maxLength: 18),
                        CreaterId = c.Int(nullable: false),
                        CreateTime = c.DateTime(nullable: false),
                        UpdaterId = c.Int(nullable: false),
                        UpdaterName = c.String(maxLength: 20),
                        UpdateTime = c.DateTime(nullable: false),
                        RowVersion = c.Binary(nullable: false, fixedLength: true, timestamp: true, storeType: "rowversion"),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.User", t => t.CreaterId)
                .ForeignKey("dbo.User", t => t.UpdaterId)
                .Index(t => t.CreaterId)
                .Index(t => t.UpdaterId);
            
            CreateTable(
                "dbo.ContractInfo",
                c => new
                    {
                        ID = c.Int(nullable: false),
                        BranchId = c.Int(),
                        SpecialId = c.Int(),
                        SellerSupplierId = c.Int(),
                        RowVersion = c.Binary(nullable: false, fixedLength: true, timestamp: true, storeType: "rowversion"),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.Branch", t => t.BranchId)
                .ForeignKey("dbo.SellerSupplier", t => t.SellerSupplierId)
                .ForeignKey("dbo.Special", t => t.SpecialId)
                .ForeignKey("dbo.Contract", t => t.ID)
                .Index(t => t.ID)
                .Index(t => t.BranchId)
                .Index(t => t.SpecialId)
                .Index(t => t.SellerSupplierId);
            
            CreateTable(
                "dbo.Contract",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        Name = c.String(nullable: false, maxLength: 50),
                        Code = c.String(nullable: false, maxLength: 21),
                        Type = c.Int(nullable: false),
                        Status = c.Int(nullable: false),
                        StartDate = c.DateTime(),
                        EndDate = c.DateTime(nullable: false),
                        CreaterId = c.Int(nullable: false),
                        CreateTime = c.DateTime(nullable: false),
                        UpdaterId = c.Int(nullable: false),
                        UpdateTime = c.DateTime(nullable: false),
                        RowVersion = c.Binary(nullable: false, fixedLength: true, timestamp: true, storeType: "rowversion"),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.User", t => t.CreaterId)
                .ForeignKey("dbo.User", t => t.UpdaterId)
                .Index(t => t.CreaterId)
                .Index(t => t.UpdaterId);
            
            CreateTable(
                "dbo.Debit",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        TypeId = c.Int(nullable: false),
                        Money = c.Decimal(nullable: false, precision: 18, scale: 4),
                        Remark = c.String(maxLength: 200),
                        DebitorId = c.Int(nullable: false),
                        DebitorName = c.String(maxLength: 20),
                        Time = c.DateTime(nullable: false),
                        RowVersion = c.Binary(nullable: false, fixedLength: true, timestamp: true, storeType: "rowversion"),
                        Insurance_ID = c.Int(),
                        Payment_ID = c.Int(),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.User", t => t.DebitorId)
                .ForeignKey("dbo.Insurance", t => t.Insurance_ID)
                .ForeignKey("dbo.Payment", t => t.Payment_ID)
                .ForeignKey("dbo.Deduction", t => t.TypeId)
                .Index(t => t.TypeId)
                .Index(t => t.DebitorId)
                .Index(t => t.Insurance_ID)
                .Index(t => t.Payment_ID);
            
            CreateTable(
                "dbo.Insurance",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        BranchId = c.Int(nullable: false),
                        BranchName = c.String(nullable: false, maxLength: 50),
                        SpecialId = c.Int(nullable: false),
                        SpecialName = c.String(nullable: false, maxLength: 50),
                        Money = c.Decimal(nullable: false, precision: 18, scale: 4),
                        Status = c.Boolean(nullable: false),
                        BuyTime = c.DateTime(nullable: false),
                        Remark = c.String(maxLength: 200),
                        InsuranceNumber = c.String(maxLength: 100),
                        InsuranceUrl = c.String(maxLength: 200),
                        RowVersion = c.Binary(nullable: false, fixedLength: true, timestamp: true, storeType: "rowversion"),
                        Buyer_ID = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.Branch", t => t.BranchId)
                .ForeignKey("dbo.User", t => t.Buyer_ID)
                .ForeignKey("dbo.Special", t => t.SpecialId)
                .Index(t => t.BranchId)
                .Index(t => t.SpecialId)
                .Index(t => t.Buyer_ID);
            
            CreateTable(
                "dbo.InsurancePerson",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        InsuranceID = c.Int(nullable: false),
                        PolicyHolder = c.String(nullable: false, maxLength: 20),
                        Sex = c.Int(nullable: false),
                        CertificatesType = c.String(nullable: false, maxLength: 20),
                        Number = c.String(nullable: false, maxLength: 50),
                        Phone = c.String(nullable: false, maxLength: 11),
                        Money = c.Decimal(nullable: false, precision: 18, scale: 4),
                        RowVersion = c.Binary(nullable: false, fixedLength: true, timestamp: true, storeType: "rowversion"),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.Insurance", t => t.InsuranceID)
                .Index(t => t.InsuranceID);
            
            CreateTable(
                "dbo.Deduction",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        Name = c.String(nullable: false, maxLength: 50),
                        Status = c.Boolean(nullable: false),
                        BranchId = c.Int(nullable: false),
                        CreaterId = c.Int(nullable: false),
                        CreateTime = c.DateTime(nullable: false),
                        UpdaterId = c.Int(nullable: false),
                        UpdateTime = c.DateTime(nullable: false),
                        RowVersion = c.Binary(nullable: false, fixedLength: true, timestamp: true, storeType: "rowversion"),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.Branch", t => t.BranchId)
                .ForeignKey("dbo.User", t => t.CreaterId)
                .ForeignKey("dbo.User", t => t.UpdaterId)
                .Index(t => t.BranchId)
                .Index(t => t.CreaterId)
                .Index(t => t.UpdaterId);
            
            CreateTable(
                "dbo.Express",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        Name = c.String(nullable: false, maxLength: 50),
                        Number = c.String(nullable: false, maxLength: 50),
                        Money = c.Decimal(nullable: false, precision: 18, scale: 4),
                        RowVersion = c.Binary(nullable: false, fixedLength: true, timestamp: true, storeType: "rowversion"),
                    })
                .PrimaryKey(t => t.ID);
            
            CreateTable(
                "dbo.Gathering",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        Drawee = c.String(nullable: false, maxLength: 20),
                        GatheringBank = c.String(nullable: false, maxLength: 20),
                        Bank = c.String(nullable: false, maxLength: 30),
                        Money = c.Decimal(nullable: false, precision: 18, scale: 4),
                        SerialNumber = c.String(nullable: false, maxLength: 100),
                        Status = c.Int(nullable: false),
                        SpecialId = c.Int(nullable: false),
                        SpecialName = c.String(),
                        SubmiterId = c.Int(nullable: false),
                        SubmiterName = c.String(nullable: false, maxLength: 20),
                        PayeeId = c.Int(),
                        PayeeName = c.String(maxLength: 20),
                        SubmitTime = c.DateTime(nullable: false),
                        CollectionTime = c.DateTime(),
                        Remark = c.String(maxLength: 200),
                        RowVersion = c.Binary(nullable: false, fixedLength: true, timestamp: true, storeType: "rowversion"),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.User", t => t.PayeeId)
                .ForeignKey("dbo.Special", t => t.SpecialId)
                .ForeignKey("dbo.User", t => t.SubmiterId)
                .Index(t => t.SpecialId)
                .Index(t => t.SubmiterId)
                .Index(t => t.PayeeId);
            
            CreateTable(
                "dbo.Invoice",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        Title = c.String(nullable: false, maxLength: 50),
                        Content = c.String(nullable: false, maxLength: 500),
                        Money = c.Decimal(nullable: false, precision: 18, scale: 4),
                        ParValueTime = c.DateTime(nullable: false),
                        Status = c.Int(nullable: false),
                        SpecialId = c.Int(nullable: false),
                        SpecialName = c.String(nullable: false, maxLength: 50),
                        SellerId = c.Int(nullable: false),
                        ExpressId = c.Int(),
                        ApplicantName = c.String(nullable: false, maxLength: 20),
                        ApplicationTime = c.DateTime(nullable: false),
                        AuditorName = c.String(maxLength: 20),
                        AuditTime = c.DateTime(),
                        AuditRemark = c.String(maxLength: 200),
                        RowVersion = c.Binary(nullable: false, fixedLength: true, timestamp: true, storeType: "rowversion"),
                        Applicant_ID = c.Int(nullable: false),
                        Auditor_ID = c.Int(),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.User", t => t.Applicant_ID)
                .ForeignKey("dbo.User", t => t.Auditor_ID)
                .ForeignKey("dbo.Express", t => t.ExpressId)
                .ForeignKey("dbo.SellerSupplier", t => t.SellerId)
                .ForeignKey("dbo.Special", t => t.SpecialId)
                .Index(t => t.SpecialId)
                .Index(t => t.SellerId)
                .Index(t => t.ExpressId)
                .Index(t => t.Applicant_ID)
                .Index(t => t.Auditor_ID);
            
            CreateTable(
                "dbo.InvoiceSubject",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        InvoiceSubjectName = c.String(nullable: false, maxLength: 50),
                        Status = c.Boolean(nullable: false),
                        Type = c.Boolean(nullable: false),
                        BranchId = c.Int(nullable: false),
                        CreaterId = c.Int(nullable: false),
                        CreateTime = c.DateTime(nullable: false),
                        UpdaterId = c.Int(nullable: false),
                        UpdateTime = c.DateTime(nullable: false),
                        RowVersion = c.Binary(nullable: false, fixedLength: true, timestamp: true, storeType: "rowversion"),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.Branch", t => t.BranchId)
                .ForeignKey("dbo.User", t => t.CreaterId)
                .ForeignKey("dbo.User", t => t.UpdaterId)
                .Index(t => t.BranchId)
                .Index(t => t.CreaterId)
                .Index(t => t.UpdaterId);
            
            CreateTable(
                "dbo.Relation_User_Menu",
                c => new
                    {
                        MenuId = c.Int(nullable: false),
                        UserId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => new { t.MenuId, t.UserId })
                .ForeignKey("dbo.Menu", t => t.MenuId, cascadeDelete: true)
                .ForeignKey("dbo.User", t => t.UserId, cascadeDelete: true)
                .Index(t => t.MenuId)
                .Index(t => t.UserId);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.InvoiceSubject", "UpdaterId", "dbo.User");
            DropForeignKey("dbo.InvoiceSubject", "CreaterId", "dbo.User");
            DropForeignKey("dbo.InvoiceSubject", "BranchId", "dbo.Branch");
            DropForeignKey("dbo.Invoice", "SpecialId", "dbo.Special");
            DropForeignKey("dbo.Invoice", "SellerId", "dbo.SellerSupplier");
            DropForeignKey("dbo.Invoice", "ExpressId", "dbo.Express");
            DropForeignKey("dbo.Invoice", "Auditor_ID", "dbo.User");
            DropForeignKey("dbo.Invoice", "Applicant_ID", "dbo.User");
            DropForeignKey("dbo.Gathering", "SubmiterId", "dbo.User");
            DropForeignKey("dbo.Gathering", "SpecialId", "dbo.Special");
            DropForeignKey("dbo.Gathering", "PayeeId", "dbo.User");
            DropForeignKey("dbo.Debit", "TypeId", "dbo.Deduction");
            DropForeignKey("dbo.Deduction", "UpdaterId", "dbo.User");
            DropForeignKey("dbo.Deduction", "CreaterId", "dbo.User");
            DropForeignKey("dbo.Deduction", "BranchId", "dbo.Branch");
            DropForeignKey("dbo.Debit", "Payment_ID", "dbo.Payment");
            DropForeignKey("dbo.Debit", "Insurance_ID", "dbo.Insurance");
            DropForeignKey("dbo.Insurance", "SpecialId", "dbo.Special");
            DropForeignKey("dbo.InsurancePerson", "InsuranceID", "dbo.Insurance");
            DropForeignKey("dbo.Insurance", "Buyer_ID", "dbo.User");
            DropForeignKey("dbo.Insurance", "BranchId", "dbo.Branch");
            DropForeignKey("dbo.Debit", "DebitorId", "dbo.User");
            DropForeignKey("dbo.Contract", "UpdaterId", "dbo.User");
            DropForeignKey("dbo.Contract", "CreaterId", "dbo.User");
            DropForeignKey("dbo.ContractInfo", "ID", "dbo.Contract");
            DropForeignKey("dbo.Attachment", "Contract_ID", "dbo.Contract");
            DropForeignKey("dbo.ContractInfo", "SpecialId", "dbo.Special");
            DropForeignKey("dbo.ContractInfo", "SellerSupplierId", "dbo.SellerSupplier");
            DropForeignKey("dbo.ContractInfo", "BranchId", "dbo.Branch");
            DropForeignKey("dbo.CollectInvoiceDetail", "GroupId", "dbo.CollectInvoiceGroup");
            DropForeignKey("dbo.CollectInvoiceDetail", "CollectInvoiceId", "dbo.CollectInvoice");
            DropForeignKey("dbo.CollectInvoice", "PaymentId", "dbo.Payment");
            DropForeignKey("dbo.Payment", "SpecialId", "dbo.Special");
            DropForeignKey("dbo.Payment", "SupplyId", "dbo.SellerSupplier");
            DropForeignKey("dbo.SellerSupplier", "UpdaterId", "dbo.User");
            DropForeignKey("dbo.SellerSupplier", "CreaterId", "dbo.User");
            DropForeignKey("dbo.PaymentEntrust", "PaymentId", "dbo.Payment");
            DropForeignKey("dbo.Attachment", "PaymentEntrust_ID", "dbo.PaymentEntrust");
            DropForeignKey("dbo.Payment", "Audit_ID", "dbo.User");
            DropForeignKey("dbo.Payment", "Applicant_ID", "dbo.User");
            DropForeignKey("dbo.CollectInvoice", "CreaterId", "dbo.User");
            DropForeignKey("dbo.CollectInvoiceGroup", "CollectInvoiceId", "dbo.CollectInvoice");
            DropForeignKey("dbo.Branch", "UpdaterId", "dbo.User");
            DropForeignKey("dbo.Branch", "CreaterId", "dbo.User");
            DropForeignKey("dbo.User", "UpdaterId", "dbo.User");
            DropForeignKey("dbo.User", "SpecialId", "dbo.Special");
            DropForeignKey("dbo.Special", "UpdaterId", "dbo.User");
            DropForeignKey("dbo.SpecialCapital", "ID", "dbo.Special");
            DropForeignKey("dbo.SpecialCapital", "Special_ID", "dbo.Special");
            DropForeignKey("dbo.Special", "CreaterId", "dbo.User");
            DropForeignKey("dbo.Special", "BranchId", "dbo.Branch");
            DropForeignKey("dbo.Relation_User_Menu", "UserId", "dbo.User");
            DropForeignKey("dbo.Relation_User_Menu", "MenuId", "dbo.Menu");
            DropForeignKey("dbo.Menu", "UpMenuId", "dbo.Menu");
            DropForeignKey("dbo.User", "CreaterId", "dbo.User");
            DropForeignKey("dbo.User", "BranchId", "dbo.Branch");
            DropIndex("dbo.Relation_User_Menu", new[] { "UserId" });
            DropIndex("dbo.Relation_User_Menu", new[] { "MenuId" });
            DropIndex("dbo.InvoiceSubject", new[] { "UpdaterId" });
            DropIndex("dbo.InvoiceSubject", new[] { "CreaterId" });
            DropIndex("dbo.InvoiceSubject", new[] { "BranchId" });
            DropIndex("dbo.Invoice", new[] { "Auditor_ID" });
            DropIndex("dbo.Invoice", new[] { "Applicant_ID" });
            DropIndex("dbo.Invoice", new[] { "ExpressId" });
            DropIndex("dbo.Invoice", new[] { "SellerId" });
            DropIndex("dbo.Invoice", new[] { "SpecialId" });
            DropIndex("dbo.Gathering", new[] { "PayeeId" });
            DropIndex("dbo.Gathering", new[] { "SubmiterId" });
            DropIndex("dbo.Gathering", new[] { "SpecialId" });
            DropIndex("dbo.Deduction", new[] { "UpdaterId" });
            DropIndex("dbo.Deduction", new[] { "CreaterId" });
            DropIndex("dbo.Deduction", new[] { "BranchId" });
            DropIndex("dbo.InsurancePerson", new[] { "InsuranceID" });
            DropIndex("dbo.Insurance", new[] { "Buyer_ID" });
            DropIndex("dbo.Insurance", new[] { "SpecialId" });
            DropIndex("dbo.Insurance", new[] { "BranchId" });
            DropIndex("dbo.Debit", new[] { "Payment_ID" });
            DropIndex("dbo.Debit", new[] { "Insurance_ID" });
            DropIndex("dbo.Debit", new[] { "DebitorId" });
            DropIndex("dbo.Debit", new[] { "TypeId" });
            DropIndex("dbo.Contract", new[] { "UpdaterId" });
            DropIndex("dbo.Contract", new[] { "CreaterId" });
            DropIndex("dbo.ContractInfo", new[] { "SellerSupplierId" });
            DropIndex("dbo.ContractInfo", new[] { "SpecialId" });
            DropIndex("dbo.ContractInfo", new[] { "BranchId" });
            DropIndex("dbo.ContractInfo", new[] { "ID" });
            DropIndex("dbo.SellerSupplier", new[] { "UpdaterId" });
            DropIndex("dbo.SellerSupplier", new[] { "CreaterId" });
            DropIndex("dbo.PaymentEntrust", new[] { "PaymentId" });
            DropIndex("dbo.Payment", new[] { "Audit_ID" });
            DropIndex("dbo.Payment", new[] { "Applicant_ID" });
            DropIndex("dbo.Payment", new[] { "SupplyId" });
            DropIndex("dbo.Payment", new[] { "SpecialId" });
            DropIndex("dbo.CollectInvoiceGroup", new[] { "CollectInvoiceId" });
            DropIndex("dbo.CollectInvoice", new[] { "CreaterId" });
            DropIndex("dbo.CollectInvoice", new[] { "PaymentId" });
            DropIndex("dbo.CollectInvoiceDetail", new[] { "GroupId" });
            DropIndex("dbo.CollectInvoiceDetail", new[] { "CollectInvoiceId" });
            DropIndex("dbo.SpecialCapital", new[] { "Special_ID" });
            DropIndex("dbo.SpecialCapital", new[] { "ID" });
            DropIndex("dbo.Special", new[] { "UpdaterId" });
            DropIndex("dbo.Special", new[] { "CreaterId" });
            DropIndex("dbo.Special", new[] { "BranchId" });
            DropIndex("dbo.Menu", new[] { "UpMenuId" });
            DropIndex("dbo.User", new[] { "UpdaterId" });
            DropIndex("dbo.User", new[] { "CreaterId" });
            DropIndex("dbo.User", new[] { "SpecialId" });
            DropIndex("dbo.User", new[] { "BranchId" });
            DropIndex("dbo.Branch", new[] { "UpdaterId" });
            DropIndex("dbo.Branch", new[] { "CreaterId" });
            DropIndex("dbo.Attachment", new[] { "Contract_ID" });
            DropIndex("dbo.Attachment", new[] { "PaymentEntrust_ID" });
            DropTable("dbo.Relation_User_Menu");
            DropTable("dbo.InvoiceSubject");
            DropTable("dbo.Invoice");
            DropTable("dbo.Gathering");
            DropTable("dbo.Express");
            DropTable("dbo.Deduction");
            DropTable("dbo.InsurancePerson");
            DropTable("dbo.Insurance");
            DropTable("dbo.Debit");
            DropTable("dbo.Contract");
            DropTable("dbo.ContractInfo");
            DropTable("dbo.SellerSupplier");
            DropTable("dbo.PaymentEntrust");
            DropTable("dbo.Payment");
            DropTable("dbo.CollectInvoiceGroup");
            DropTable("dbo.CollectInvoice");
            DropTable("dbo.CollectInvoiceDetail");
            DropTable("dbo.SpecialCapital");
            DropTable("dbo.Special");
            DropTable("dbo.Menu");
            DropTable("dbo.User");
            DropTable("dbo.Branch");
            DropTable("dbo.Attachment");
        }
    }
}
